package com.dtflys.forest.testserver.client;

import com.dtflys.forest.annotation.*;
import com.dtflys.forest.callback.OnProgress;
import org.springframework.core.io.Resource;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.InputStream;
import java.util.Map;

@BaseRequest(baseURL = "localhost:8087")
public interface UploadClient {

    @Request(
            url = "/upload",
            type = "post",
            dataType = "json",
            contentType = "multipart/form-data"
    )
    Map upload(@DataFile("file") String filePath, @Body("flag") String flag, OnProgress onProgress);


    @Request(
            url = "http://60.191.98.35:8193/chat/msgfile/upload.do",
            type = "post",
            dataType = "json",
            contentType = "multipart/form-data"
    )
    Map uploadTest2(@DataFile("file") String filePath, OnProgress onProgress);

    @Post(url = "/upload")
    Map upload(@DataFile("file") File file, @Body("flag") String flag, OnProgress onProgress);

    @Post(url = "/upload")
    Map upload(@DataFile(value = "file", fileName = "${1}") byte[] bytes, String filename, @Body("flag") String flag);

    @Post(url = "/upload")
    Map upload(@DataFile(value = "file", fileName = "${1}") InputStream in, String filename, @Body("flag") String flag);


    @Post(url = "/upload")
    Map upload(@DataFile(value = "file") Resource resource, @Body("flag") String flag);

    @PostRequest(url = "/upload")
    Map upload(@DataFile(value = "file") MultipartFile multipartFile, @Body("flag") String flag, OnProgress onProgress);

    @PostRequest(url = "http://60.191.98.35:8193/chat/msgfile/upload.do")
    String uploadTest2(@DataFile(value = "file") MultipartFile multipartFile);


    @Post(url = "http://118.178.187.113:10002/oss/upload")
    Map upload3(@DataParam("root") String root, @DataParam("type") String type, @DataParam("nameType") String nameType,  @DataFile("file") MultipartFile file);
}
